//
//  SPPetingListCell.swift
//  SparklingPets
//
//  Created by iOS-Czz on 2023/10/26.
//

import UIKit

class SPPetingListCell: UITableViewCell {
   
    @IBOutlet var pic: UIImageView!
    @IBOutlet var photoView: UIView!
    
    @IBOutlet var petIcon: UIImageView!
    @IBOutlet var nameLabel: UILabel!
    @IBOutlet var size1Label: UILabel!
    @IBOutlet var size2Label: UILabel!
    @IBOutlet var size3Label: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    override func layoutIfNeeded() {
        super.layoutIfNeeded()
        self.photoView.addRoundCorners(topLeftRadius: 10, topRightRadius: 54, bottomLeftRadius: 10, bottomRightRadius: 54, borderWidth: 0, borderColor: .clear)
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }

    var model: SPPetModel? {
        didSet {
            self.pic.image = UIImage.loadImage((model?.picture)!)
            self.nameLabel.text = model?.name
            self.petIcon.image = UIImage(named: PET_ICONS[model!.type])
            self.size1Label.attributedText = NSAttributedString.coloredString(originalText: "\(model!.sizeName1) \(model!.size1)", coloredSubText: model!.sizeName1, colorForColoredText: .gray)
            self.size2Label.attributedText = NSAttributedString.coloredString(originalText: "\(model!.sizeName2) \(model!.size2)", coloredSubText: model!.sizeName2, colorForColoredText: .gray)
            self.size3Label.attributedText = NSAttributedString.coloredString(originalText: "\(model!.sizeName3) \(model!.size3)", coloredSubText: model!.sizeName3, colorForColoredText: .gray)
        }
    }
    
}
